home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 255_01 / gpscale.asm < prev    next >
Encoding:
Assembly Source File  |  1988-03-28  |  1.8 KB  |  56 lines

  1.           page   80,132
  2.           page
  3. ;
  4. ;         Kent Cedola
  5. ;         2015 Meadow Lake Court
  6. ;         Norfolk, Virginia  23518
  7. ;
  8.  
  9. dgroup    group  _data
  10.  
  11. _data     segment word public 'data'
  12.           assume ds:dgroup
  13.  
  14.           extrn  _gdwd_x1:word,_gdwd_x2:word,_gdwd_x3:word
  15.           extrn  _gdwd_y1:word,_gdwd_y2:word,_gdwd_y3:word
  16.           extrn  _gdvw_x1:word,_gdvw_x2:word,_gdvw_x3:word
  17.           extrn  _gdvw_y1:word,_gdvw_y2:word,_gdvw_y3:word
  18.           extrn  _gdc_flg:byte
  19.  
  20. _data     ends
  21.  
  22. _text     segment byte public 'code'
  23.  
  24.           assume cs:_text,ds:dgroup
  25.           public _gpscale
  26. _gpscale  proc   near
  27.  
  28.           push   bp
  29.           mov    bp,sp
  30.  
  31.           push   si
  32.  
  33.           mov    si,[bp+4]
  34.           MOV    AX,[si]               ; Copy X coordinate to a work register
  35.           SUB    AX,_gdwd_x1           ; Substract the Window's X offset
  36.           IMUL   _gdvw_x3              ; Multiply by the Viewport's X delta
  37.           IDIV   _gdwd_x3              ; Divide by the Window's X offset
  38.           ADD    AX,_gdvw_x1           ; Add the Viewport's X offset
  39.           MOV    [si],ax               ; Copy the converted X back
  40.  
  41.           mov    si,[bp+6]
  42.           MOV    AX,[si]               ; Copy Y coordinate to a work register
  43.           SUB    AX,_gdwd_y1           ; Substract the Window's Y offset
  44.           IMUL   _gdvw_y3              ; Multiply by the Viewport's Y delta
  45.           IDIV   _gdwd_y3              ; Divide by the Window's Y offset
  46.           ADD    AX,_gdvw_y1           ; Add the Viewport's Y offset
  47.           MOV    [si],ax               ; Copy the converted Y back
  48.  
  49.           pop    si
  50.           pop    bp
  51.           ret
  52.  
  53. _gpscale  endp
  54. _text     ends
  55.           end
  56.